import http from '@/http/index';
import type { Result } from '@/http/type';
import type { DeviceMaterial, DeviceMaterialQuery } from './type';

const api = {
  list: '/api/device-material/page',
  detail: '/api/device-material',
  add: '/api/device-material',
  update: '/api/device-material',
  delete: '/api/device-material',
};

/**
 * 分页查询设备物料
 * @param params 查询参数
 */
export function getDeviceMaterialList(params: DeviceMaterialQuery) {
  return http.get<Result>(api.list, params);
}

/**
 * 获取设备物料详情
 * @param id 设备物料ID
 */
export function getDeviceMaterialDetail(id: number | string) {
  return http.get<Result>(`${api.detail}/${id}`);
}

/**
 * 新增设备物料
 * @param data 设备物料数据
 */
export function addDeviceMaterial(data: DeviceMaterial) {
  return http.post<Result>(api.add, data);
}

/**
 * 更新设备物料
 * @param data 设备物料数据
 */
export function updateDeviceMaterial(data: DeviceMaterial) {
  return http.put<Result>(api.update, data);
}

/**
 * 删除设备物料
 * @param id 设备物料ID
 */
export function deleteDeviceMaterial(id: number | string) {
  return http.delete<Result>(`${api.delete}/${id}`);
} 